
//添加学员回复
function addEvaluationReply(id){
	var dataContent="";
	dataContent+='<div style="text-align: center;margin-top:10px;"><textarea id="reply" style="height:300px;width:90%"/></div>';
	dataContent+='<button type="button" class="btn btn-primary btn-sm " style="margin-top:35px;margin-left:35%" onclick="saveEvaluationReply('+id+')"> 提  交 </button>&nbsp;&nbsp;';
	dataContent+='<button type="button" class="btn btn-primary btn-sm " style="margin-top:35px;margin-left:10%" onclick="layerClose()"> 关  闭 </button>&nbsp;&nbsp;';
	layer.open({
		  type: 1,
		  skin: 'layui-layer-rim', //加上边框
		  area: ['550px', '500px'], //宽高
		  content: dataContent,
		  title: '评价回复',
	});
}

//查看学员回复
function showEvaluationReply(id){
	$.ajax({    
	    type:'post',        
	    url:'ajax/lessons_selectEvaluationReply.action',    
	    data:{'lessonId' : id},    
	    cache:false,    
	    dataType:'json',
	    success:function(data){  
	    	console.info(data);
	    	if(data.state>0){ 
	    		var dataContent="";
	    		dataContent+='<div style="text-align: center;margin-top:10px;"><textarea id="reply" style="height:300px;width:90%" readonly>'+data.lessons.evaluationReply+'</textarea></div>';
	    		dataContent+='<button type="button" class="btn btn-primary btn-sm " style="margin-top:35px;margin-left:45%" onclick="layerClose()"> 关      闭 </button>&nbsp;&nbsp;';
	    		layer.open({
	    			  type: 1,
	    			  skin: 'layui-layer-rim', //加上边框
	    			  area: ['550px', '500px'], //宽高
	    			  content: dataContent,
	    			  title: '查看回复',
	    		});
	        }  
	   },    
	  error : function(xhr, type, exception) {    
	       // view("异常！");  
		  layer.alert(xhr.responseText, "Failed"); 
	       //alert("删除数据异常，请与管理员联系！");    
	  }   
	     
	});
}



function layerClose(){
	layer.closeAll();
}
//提交回复
function saveEvaluationReply(id){
	if($("#reply").val()=="" || $("#reply").val() ==null){
		layer.alert("请填写回复");
		return;
	}
	$.ajax({    
	    type:'post',        
	    url:'ajax/lessons_saveEvaluationReply.action',    
	    data:{'lessonId' : id,"results":$("#reply").val()},    
	    cache:false,    
	    dataType:'json',
	    success:function(data){  
	    	if(data.state>0){  
	    		layer.msg("数据提交成功",{
                          offset:['50%'],
                          time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        },function(){
	    					layerClose();
                         	location.reload();
				});
	        }  
	   },    
	  error : function(xhr, type, exception) {    
	       // view("异常！");  
		  layer.alert(xhr.responseText, "Failed"); 
	       //alert("删除数据异常，请与管理员联系！");    
	  }   
	     
	});
}



String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
